<?php
declare (strict_types=1);

namespace app\common\model;
use think\model\relation\BelongsTo;

class OrderLogistics extends Base
{
    protected $name = 'order_logistics';

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'uid', 'id')->field('id,code,nickname,mobile');
    }

    public function orders(): BelongsTo
    {
        return $this->belongsTo(Order::class, 'order_id', 'id');
    }

    public function getProductsAttr($value, $data)
    {
        return OrderProduct::where('order_id', $data['order_id'])->whereIn('pid', $data['product_ids'])->select();
    }
}
